<?php 
class admin_model extends CI_Model {
        function __construct()
        {
                parent::__construct();        
                $this->load->helper("local");
                $this->load->helper('date');
                $this->load->database();
        } 
//START-----------------Brocker / Customer-------------------------//              
        function admin_all_driver_vendor()
        {
			$this->load->database();
                $query = $this->db->query('select * from profile order by profile_id DESC');
                $_result =''; $profile_type='';	$priority_code='';$bc_company_name='';$bc_n_name='';$f_name=''; $l_name=''; $cell_phone_num='';$office_phone_num='';$email_add='';$trailer_num='';$truck_num='';$mc_num='';$comment_box='';
				$_result .=
                "<p class=''><table border='0'><tr><td></td></tr></td></table></p>
                <table width='940' class='Grid' border='1'>
                  <tr>
	 				   <th width='40'><div align='center'>Profile Type</div></th>
                        <th width='40'><div align='center'>Priority Code</div></th>
                        <th width='80'><div align='center'>Company Name</div></th>
                        <th width='40'><div align='center'>Nick Name</div></th>
                        <th width='40'><div align='center'>First Name</div></th>
                        <th width='40'><div align='center'>Last Name</div></th>
						<th width='60'><div align='center'>Mobile Number</div></th>
                        <th width='60'><div align='center'>Office Number</div></th>
						<th width='70'><div align='center'>Email</div></th>
						<th width='50'><div align='center'>Trailer Number</div></th>
						<th width='50'><div align='center'>Truck Number</div></th>
                        <th width='40'><div align='center'>MC Number</div></th>
                        <th width='150'><div align='center'>Comment</div></th>
                        <th width='32'><div align='center'></div></th>
                        <th width='24'><div align='center'></div></th>
                        <th width='39'><div align='center'></div></th>
                  </tr>";
				  $_rowClass = 'tr_odd';
                foreach($query->result() as $row)
                {
						
                        if(strlen($row->profile_type)>5 )
                        {
                                $profile_type = substr($row->profile_type,0,5)."...<a href='" .base_url()."admin/view_driver_vendor/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $profile_type = $row->profile_type;}
                        

                        if(strlen($row->priority_code)>5 )
                        {
                                $priority_code = substr($row->priority_code,0,5)."... <a href='" .base_url()."admin/view_driver_vendor/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $priority_code = $row->priority_code;}

                        if(strlen($row->bc_company_name)>10 )
                        {
                                $bc_company_name = substr($row->bc_company_name,0,10)."... <a href='" .base_url()."admin/view_driver_vendor/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $bc_company_name = $row->bc_company_name;}
						
                        if(strlen($row->bc_n_name)>5 )
                        {
                                $bc_n_name = substr($row->bc_n_name,0,5)."... <a href='" .base_url()."admin/view_driver_vendor/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $bc_n_name = $row->bc_n_name;}
						
						 if(strlen($row->f_name)>5 )
                        {
                                $f_name = substr($row->f_name,0,5)."... <a href='" .base_url()."admin/view_driver_vendor/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $f_name = $row->f_name;}
						
						 if(strlen($row->l_name)>5 )
                        {
                                $l_name = substr($row->l_name,0,5)."... <a href='" .base_url()."admin/view_driver_vendor/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $l_name = $row->l_name;}
						
						 if(strlen($row->cell_phone_num)>7 )
                        {
                                $cell_phone_num = substr($row->cell_phone_num,0,7)."... <a href='" .base_url()."admin/view_driver_vendor/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $cell_phone_num = $row->cell_phone_num;}
						
						 if(strlen($row->office_phone_num)>7 )
                        {
                         $office_phone_num = substr($row->office_phone_num,0,7)."... <a href='" .base_url()."admin/view_driver_vendor/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $office_phone_num = $row->office_phone_num;}
						
						if(strlen($row->email_add)>15 )
                        {
                         $email_add = substr($row->email_add,0,15)."... <a href='" .base_url()."admin/view_driver_vendor/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $email_add = $row->email_add;}
						
			
						if(strlen($row->trailer_num)>7 )
                        {
                         $trailer_ = substr($row->trailer_num,0,7)."... <a href='" .base_url()."admin/view_driver_vendor/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $trailer_ = $row->trailer_num;}
						
						
						if(strlen($row->truck_num)>7 )
                        {
                         $truck_num = substr($row->truck_num,0,7)."... <a href='" .base_url()."admin/view_driver_vendor/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $truck_num = $row->truck_num;}
						
						if(strlen($row->mc_num)>5 )
                        {
                         $mc_num = substr($row->mc_num,0,5)."... <a href='" .base_url()."admin/view_driver_vendor/".$row->profile_id."'>Read More</a>" ;
                        }
                        else{ $mc_num = $row->mc_num;}
					
					
                        $_result.="
					<tr class='".$_rowClass."' ".GetTrEffects().">
						<td><div align='left'>".$profile_type."</div></td>
                        <td><div align='left'>".$priority_code."</div></td>
                        <td><div align='left'>".$bc_company_name."</div></td>
                        <td><div align='left'>".$bc_n_name."</div></td>
                        <td><div align='left'>".$f_name."</div></td>
                        <td><div align='left'>".$l_name."</div></td>
                        <td><div align='left'>".$cell_phone_num."</div></td>
                        <td><div align='left'>".$office_phone_num."</div></td>
						<td><div align='left'>".$email_add."</div></td>
						<td><div align='left'>".$trailer_num."</div></td>
 						<td><div align='left'>".$truck_num."</div></td>
						<td><div align='left'>".$mc_num."</div></td>
						
                        <td width='5'><div align='center'><a href='" .base_url()."admin/view_driver_vendor/".$row->profile_id."'><img src='".base_url()."images/icons/view.gif' style='border:none'/></a></div></td>
                        <td width='5'><div align='center'><a href='".base_url()."admin/edit_driver_vendor/".$row->profile_id."'><img src='".base_url()."images/icons/edit.gif' style='border:none' /></a></div></td>
                        <td width='5'><div align='center'><a href='".base_url()."admin/delete_driver_vendor/".$row->profile_id."'><img src='".base_url()."images/icons/delete.gif' style='border:none' /></a></div></td>
                  </tr>";
				  if($_rowClass=="tr_odd") $_rowClass="tr_even"; else $_rowClass="tr_odd";     
                 }
                        $_result .="</table>"; 
                return($_result);
        }


		
        function add_view_driver_vendor(){
                $_result ="";
           $_result .="<h1>Add Driver / Vendor </h1>";
       					   $_result .="<form method='post' action='".base_url()."admin/p_add_driver_vendor'>";
		                   $_result .="<div align='left' width='100'>Profile_type";
						   $_result .="<textarea rows='1' cols='15' name='txtprofile_type'></textarea> <br/>";	
						   $_result .="<div align='left' width:'100'>Priority_code";
						   $_result .="<textarea rows='1' cols='15' name='txtpriority_code'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Company Name";
						   $_result .="<textarea rows='1' cols='15' name='txtbc_company_name'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Nick Name";
						   $_result .="<textarea rows='1' cols='15' name='txtbc_n_name'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>First Name";
						   $_result .="<textarea rows='1' cols='15' name='txtf_name'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Last Name";
						   $_result .="<textarea rows='1' cols='15' name='txtl_name'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Mobile Number";
   						   $_result .="<textarea rows='1' cols='15' name='txtcell_phone_num'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Office Number";
						   $_result .="<textarea rows='1' cols='15' name='txtoffice_phone_num'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Email Address";
						   $_result .="<textarea rows='1' cols='15' name='txtemail_add'></textarea><br/>";
   						   $_result .="<div align='left' width:'100'>Trailer Number";
						   $_result .="<textarea rows='1' cols='15' name='txttrailer_num'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Truck Number";
						   $_result .="<textarea rows='1' cols='15' name='txttruck_num'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>MC Number";
   						   $_result .="<textarea rows='1' cols='15' name='txtmc_num'></textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Comment Box";
						   $_result .="<textarea rows='20' cols='30' name='txtcomment_box'></textarea> <br/> ";
						   $_result .="<br/>
										<table border='0'>
										  <tr>
											<td>
											   <input type='submit' name='cmdsave' value='Save' style='background-image:url(".base_url()."images/icons/save.gif);	background-position:left;background-color:transparent;background-repeat:no-repeat;text-align:right;width:60px;border:none transparent;color:#0000FF;cursor:pointer;' />
											</td>
											<td>
											</td>
											<td>
											   <input type='submit' name='cmdcancel' value='Cancel' style='background-image:url(".base_url()."images/icons/cancel.gif);	background-position:left;background-color:transparent;background-repeat:no-repeat;text-align:right;width:70px;border:none transparent;color:#0000FF;cursor:pointer;' />
											</td>
										   </tr>
										 </table>
									   ";
                          
                   $_result .="</div>";
       $_result .="</form>";
           return($_result);
                                        
        }

        function admin_view_driver_vendor($code)
        { 
                $query = $this->db->query("select * from profile where profile_id='$code'");
                $_result ='';
                foreach($query->result() as $row);
                {
								$_result .="<br/><p>".$row->profile_type."</p";
                                $_result .="<br/><p>".$row->priority_code."</p";
								$_result .="<br/><p>".$row->bc_company_name."</p";
								$_result .="<br/><p>".$row->bc_n_name."</p";
								$_result .="<br/><p>".$row->f_name."</p";
								$_result .="<br/><p>".$row->l_name."</p";
								$_result .="<br/><p>".$row->cell_phone_num."</p";
								$_result .="<br/><p>".$row->office_phone_num."</p";
								$_result .="<br/><p>".$row->email_add."</p";
								$_result .="<br/><p>".$row->trailer_num."</p";							
								$_result .="<br/><p>".$row->truck_num."</p";								
								$_result .="<br/><p>".$row->mc_num."</p";
								$_result .="<br/><p>".$row->comment_box."</p";
                                $_result .="<div align='right'><table border='0'><tr><td><a href='".base_url()."admin' ><img src='".base_url()."images/icons/back.jpg' style='border:none;'/></a></td><td><a href='".base_url()."admin'>Back to Brocker/Customer List</a></td></te></table></div>";
                        $_result .="</div>";            
                }               
                return($_result);
        }
		
        function admin_edit_driver_vendor($code)
        {        
                $query = $this->db->query("select * from profile where profile_id='$code'");
                $_result ='';
               // $action_url= base_url()."";
                foreach($query->result() as $row);
                {
				$_result .="<form method='post' action='".base_url()."admin/p_edit_driver_vendor/".$row->profile_id."'";
						   $_result .="<div align='left' width='100'>Profile_type";
						   $_result .="<textarea rows='1' cols='15' name='txtprofile_type'>".$row->profile_type."</textarea> <br/>";	
						   $_result .="<div align='left' width:'100'>Priority_code";
						   $_result .="<textarea rows='1' cols='15' name='txtpriority_code'>".$row->priority_code."</textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Company Name";
						   $_result .="<textarea rows='1' cols='15' name='txtbc_company_name'>".$row->bc_company_name."</textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Nick Name";
						   $_result .="<textarea rows='1' cols='15' name='txtbc_n_name'>".$row->bc_n_name."</textarea> <br/>";
						   $_result .="<div align='left' width:'100'>First Name";
						   $_result .="<textarea rows='1' cols='15' name='txtf_name'>".$row->f_name."</textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Last Name";
						   $_result .="<textarea rows='1' cols='15' name='txtl_name'>".$row->l_name."</textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Mobile Number";
   						   $_result .="<textarea rows='1' cols='15' name='txtcell_phone_num'>".$row->cell_phone_num."</textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Office Number";
						   $_result .="<textarea rows='1' cols='15' name='txtoffice_phone_num'>".$row->office_phone_num."</textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Email Address";
						   $_result .="<textarea rows='1' cols='15' name='txtemail_add'>".$row->email_add."</textarea><br/>";
   						   $_result .="<div align='left' width:'100'>Trailer Number";
						   $_result .="<textarea rows='1' cols='15' name='txttrailer_num'>".$row->trailer_num."</textarea> <br/>";
   						   $_result .="<div align='left' width:'100'>Truck Number";
					       $_result .="<textarea rows='1' cols='15' name='txttruck_num'>".$row->truck_num."</textarea> <br/>";
						   $_result .="<div align='left' width:'100'>MC Number";
   						   $_result .="<textarea rows='1' cols='15' name='txtmc_num'>".$row->mc_num."</textarea> <br/>";
						   $_result .="<div align='left' width:'100'>Comment Box";
						   $_result .="<textarea rows='20' cols='30' name='txtcomment_box'>".$row->comment_box."</textarea> <br/> ";
                        
                                       // $_result .="<br/><input type='submit' name='cmdupdate' id='cmdupdate' value='Update' />";
										$_result .="<br/>
													<table>
														<tr>
															<td>
																<input type='submit' name='cmdupdate' value='Update' style='background-image:url(".base_url()."images/icons/edit.gif);
	background-position:left;background-color:transparent;background-repeat:no-repeat;text-align:right;width:70px;border:none transparent;color:#0000FF;cursor:pointer;' /></td>
															<td></td>
															<td><input type='submit' name='cmdcancel' value='Cancel' style='background-image:url(".base_url()."images/icons/cancel.gif);
	background-position:left;background-color:transparent;background-repeat:no-repeat;text-align:right;width:70px;border:none transparent;color:#0000FF;cursor:pointer;' /></td>
															
														</tr>
													</table>
													";
                                                                   
                                $_result .="</div>";
                        $_result .="</form>
						"; 
						
                }

                return($_result);
        }
		

}
?>
